﻿using Newtonsoft.Json;

namespace DingTalk.Core.Models
{
    /// <summary>
    /// 
    /// </summary>
    [JsonObject]
    public class AccessToken : StandardResponse
    {
        /// <summary>
        /// 
        /// </summary>
        public string Token { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int ExpiresIn { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return Token;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="accessToken"></param>
        public static implicit operator String(AccessToken accessToken)
        {
            if (accessToken == null)
                return null;
            return accessToken.ToString();
        }
    }
    /// <summary>
    /// 新版钉钉 api 调用的基础令牌请求
    /// {
    ///   "appKey" : "dingeqqpkv3xxxxxx",
    ///   "appSecret" : "GT-lsu-taDAxxxsTsxxxx"
    /// }
    /// </summary>
    [JsonObject]
    public class AccessTokenRequest
    {
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("appKey")]
        public string AppKey { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("appSecret")]
        public string AppSecret { get; set; }
    }
    /// <summary>
    /// 新版钉钉 api 调用的基础令牌响应
    /// { 
    ///     "accessToken":"ACCESS_TOKEN",
    ///     "expireIn":7200,
    /// }
    /// </summary>
    [JsonObject]
    public class AccessTokenResponse 
    {
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("accessToken")]
        public string AccessToken { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("expireIn")]
        public int ExpiresIn { get; set; }
    }
}
